<template>
  <div id="app">
    <router-view name="Header"></router-view>
    <router-view></router-view>
    <router-view name="Side"></router-view>
    <router-view name="Footer"></router-view>
  </div>
</template>
<script>
import store from "./store";
import router from "./router";
import RouterView from "./RouterView";
export default {

  beforeunload: function() {
    alert("您输入的内容尚未保存，确定离开此页面吗？");
  },
  beforeCreate() {
   window.addEventListener("beforeunload", () => {
      localStorage.setItem("messageStore", JSON.stringify(this.$store.state));
    });
    localStorage.getItem("messageStore") &&
      this.$store.replaceState(
        Object.assign(
          this.$store.state,
          JSON.parse(localStorage.getItem("messageStore"))
        )
      );
      var userdata = store.state.userDATA;
      // console.log("app 请求渲染一次路由",userdata.token,userdata.token != null,userdata.token == '');
      this.$store.commit("UserRouterUpdata");

            // console.log('打印目前路由',this.$router.options,this.$router.resolve)

    // if (userdata.token != '') {
    //   // this.$store.commit("userRolesUpdata",'user');
    //   this.$store.commit("UserRouterUpdata");
    //   console.log("app 渲染一次路由");
    // }
    // 渲染主页导航内容
  }

};
</script>

<style lang="scss" type="text/css">
@import "./common/style.scss"; //导入外部scss文件
</style>
